home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1998 #1
/
Amiga Plus 1998 #1.iso
/
pd
/
grafik
/
mysticube
/
source
/
timer.asm
< prev
next >
Wrap
Assembly Source File
|
1997-08-12
|
2KB
|
118 lines
section text
XDEF _timerstart
XDEF _timerstop
include "devices/timer.i"
include "lvo/timer_lib.i"
include "lvo/exec_lib.i"
include "exec/memory.i"
;====================================================================
;--------------------------------------------------------------------
;
; handle = timerstart()
; d0
; initialisiert und startet den Timer.
;
; millisec = timerstop(handle)
; d0 d0
;
; liest den Timer und liefert
; die Anzahl der Tausendstel Sekunden.
;
;--------------------------------------------------------------------
STRUCTURE mytimer,0
APTR timer_base
STRUCT timer_request,IOTV_SIZE
DOUBLE timer_val1
DOUBLE timer_val2
LABEL timer_SIZEOF
;--------------------------------------------------------------------
_timerstart: movem.l d1-a6,-(a7)
move.l 4.w,a6
moveq #timer_SIZEOF,d0
moveq #MEMF_ANY,d1
jsr (_LVOAllocVec,a6)
tst.l d0
beq.b .exit
move.l d0,a5
clr.l (timer_base,a5)
lea (timer_name,pc),a0
lea (timer_request,a5),a1
moveq #0,d0
moveq #0,d1
jsr (_LVOOpenDevice,a6)
tst.b d0
bne.b .fail
move.l (timer_request+IO_DEVICE,a5),a6
move.l a6,(timer_base,a5)
lea (timer_val1,a5),a0
jsr (_LVOReadEClock,a6)
move.l a5,d0
bra.b .exit
.fail move.l a5,a1
jsr (_LVOFreeVec,a6)
moveq #0,d0
.exit movem.l (a7)+,d1-a6
rts
;--------------------------------------------------------------------
_timerstop: movem.l d1-a6,-(a7)
move.l d0,a5
move.l (timer_base,a5),d0
beq.b timer_error
move.l d0,a6
lea (timer_val2,a5),a0
jsr (_LVOReadEClock,a6)
move.l d0,d4 ; Timer-Frequenz [Hz]
movem.l (timer_val1,a5),d2/d3
movem.l (timer_val2,a5),d0/d1
sub.l d3,d1
subx.l d2,d0
mulu.l #1000,d0:d1
divu.l d4,d0:d1 ; tausendstel Sekunden
move.l d1,d2
lea (timer_request,a5),a1
move.l 4.w,a6
jsr (_LVOCloseDevice,a6)
move.l a5,a1
move.l 4.w,a6
jsr (_LVOFreeVec,a6)
move.l d2,d0
timer_error movem.l (a7)+,d1-a6
rts
;--------------------------------------------------------------------
timer_name dc.b "timer.device",0
even
;====================================================================